<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>美嘉饲料</title>
<link href="<%=basePath%>skin/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=basePath%>skin/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="<%=basePath%>skin/js/common.js"></script>
<script language="javascript">
$().ready(function(){
	 $("#menu_address").attr("class","select");
	 $("#add").click(function(){
		 window.location.href="<%=basePath%>member/receiver/add.shtml";
	 });
	 
	 var $delete = $("a.delete");
	 $delete.click(function(){
		 if(confirm("确定要删除收货地址吗？")) {
			 var $this = $(this);
			 var $tr = $this.closest("tr");
			 var id = $tr.find("input[name='id']").val();
			 $.ajax({
					url: "<%=basePath%>member/receiver/delete.shtml",
					type: "POST",
					data: {id: id},
					cache: false,
					beforeSend: function() {
						$delete.prop("disabled", true);
					},
					success: function(data) {
						var success = data.success;
						if (success == "true") {
							alert("收货地址删除成功");
						} else {
							alert("收货地址删除失败");
						}
						location.reload(true);
					},
					complete: function() {
						$delete.prop("disabled", false);
					}
				});
		 }
		 return false;
	 });
});
</script>
</head>
  
<body>
<div class="nb-smt"></div>
<div id="container" class="wkg">
<c:import url="/layouts/top.jsp" />
<div id="content">
        <c:import url="/layouts/head.jsp" />
        <div id="main">
        	<c:import url="../left.jsp" />
			<div id="myRight">
			<div class="myRightTitle">
				<div class="mrtl">
					收货地址
				</div>
				<div class="mrtr">
					<input type="button" id="add" name="add" value="添加收货地址" />
				</div>
				<div class="clear"></div>
			</div>
			<div class="myRightContent">
				<table cellspacing="0" cellpadding="0">
					<tr>
						<td width="15%">收货人</td>
						<td width="20%">地区</td>
						<td width="20%">地址</td>
						<td width="10%">邮编</td>
						<td width="15%">手机</td>
						<td width="10%">是否默认</td>
						<td width="10%">操作</td>
					</tr>
					<c:forEach items="${receivers }" var="receiver">
					<tr>
						<td>
							<input type="hidden" name="id" value="${receiver.id}" />
							${receiver.consignee }
						</td>
						<td>${receiver.areaName }</td>
						<td>${receiver.address }</td>
						<td>${receiver.zipCode }</td>
						<td>${receiver.phone }</td>
						<td>
							<c:choose>
								<c:when test="${receiver.isDefault }">是</c:when>
								<c:otherwise>否</c:otherwise>
							</c:choose>
						</td>
						<td>
							<a href="<%=basePath%>member/receiver/edit.shtml?id=${receiver.id}">编辑</a>
							<a href="javascript:;" class="delete">删除</a>
						</td>
					</tr>
					</c:forEach>
				</table><br/>
			</div>
			</div>
        </div>
        <div class="clear"></div>
    </div>
</div>
<c:import url="/layouts/foot.jsp" />
</body>
</html>


